﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using r4u.data.access.layer;
using r4u.data.access.layer.RECRUIT;

namespace r4u.business.logic.layer.RECRUIT
{
    public class Skill
    {
        /// <summary>
        /// A unique identifier for a single skill in the list of skills
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// A structured object that indicates the internationalized name of the canonical language
        /// </summary>
        public string Name { get; set; }


        public Skill(int Id, string Name)
        {
            this.Id = Id;
            this.Name = Name;
        }

        public Skill() { }


        public bool Insert(VACANCY_SKILL skill)
        {
            SkillDAO skillDao = new SkillDAO();
            return skillDao.Insert(skill);
        }

        public bool Delete(string vacancy_id, string skill_id)
        {
            SkillDAO skillDao = new SkillDAO();
            return skillDao.Delete(vacancy_id, skill_id);
        }


        public SkillObject[] List(string vacancy_id)
        {
            SkillDAO skillDao = new SkillDAO();
            List<SkillObject> skills = new List<SkillObject>();

            foreach (VACANCY_SKILL skill in skillDao.List(vacancy_id))
            {
                SkillObject s = new SkillObject();
                s.vacancy_id = skill.vacancy_id;
                s.skill_id = skill.skill_id;
                s.optional = skill.optional;
                skills.Add(s);
            }

            return skills.ToArray();
        }

    }
}
